package 反射3;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public class TestUserReflection {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Class<User> userClass = User.class;
        User o = userClass.newInstance();
        System.out.println("o = " + o);

        Constructor<User> constructor = userClass.getConstructor(String.class);
        User hsp = constructor.newInstance("aaaa");
        System.out.println("hsp = " + hsp);

        Constructor<User> constructor1 = userClass.getConstructor(int.class, String.class);
        //  constructor1.setAccessible(true);
        User lisi = constructor1.newInstance(90, "李四");
        System.out.println("lisi = " + lisi);


    }
}